<template>
	<view>
    <!-- 公积金  -->
    <commonWin> </commonWin>
    <view class="top tac fw">
      <text>请完善</text>
      <text class="color">基本信息</text>
    </view>

    <view class="messageBar fz12">
      <view class="disb aic" @click="click(2)">
        <text>是否名下有房产（重庆）</text>
        <view class="select disp aic" style="font-weight: 700">
          <text class="color10">{{house.isHouse?house.isHouse:'请选择'}}</text>
          <image src="../../static/images/preat/right.png" mode=""></image>
        </view>
      </view>
    </view>

    <view class="messageBar fz12">
      <view class="disb aic" @click="click(3)">
        <text>房产状态</text>
        <view class="select disp aic" style="font-weight: 700">
          <text class="color10">{{house.propertyStatus?house.propertyStatus:'请选择'}}</text>
          <image src="../../static/images/preat/right.png" mode=""></image>
        </view>
      </view>
    </view>

    <view class="messageBar fz12">
      <view class="disb aic">
        <text>单位工作时间</text>
        <view class="select disp aic" style="font-weight: 700">
          <u-input
              type="number"
              maxlength="10"
              placeholder="请输入"
              inputAlign='right'
              border='none'
              v-model="house.unitTime"
          ></u-input>
          <text>个月以上</text>
        </view>
      </view>
    </view>

    <view class="messageBar fz12">
      <view class="disb aic" @click="click(5)">
        <text>单位性质</text>
        <view class="select disp aic" style="font-weight: 700">
          <text class="color10">{{house.natureOfUnit?house.natureOfUnit:'请选择'}}</text>
          <image src="../../static/images/preat/right.png" mode=""></image>
        </view>
      </view>
    </view>

<!--		<view class="messageBar fz12">-->
<!--			<view class="disb aic" @click="click(1)">-->
<!--				<text>是否一次性缴费</text>-->
<!--				<view class="select disp aic" style="font-weight: 700">-->
<!--					<text class="color10">{{house.isPayment?house.isPayment:'请选择'}}</text>-->
<!--					<image src="../../static/images/preat/right.png" mode=""></image>-->
<!--				</view>-->
<!--			</view>-->
<!--		</view>-->



		<view class="messageBar fz12">
			<view class="disb aic" @click="click(6)">
				<text>职务</text>
				<view class="select disp aic" style="font-weight: 700">
					<text class="color10">{{house.job?house.job:'请选择'}}</text>
					<image src="../../static/images/preat/right.png" mode=""></image>
				</view>
			</view>
		</view>

		<view class="messageBar fz12">
			<view class="disb aic">
				<text>年缴费</text>
				<view class="select disp aic" style="font-weight: 700">
					<u-input
            maxlength="10"
            type='digit'
					  placeholder="请输入"
						inputAlign='right'
						border='none'
					    v-model="house.policyYearPayment"
					></u-input>
				</view>
			</view>
		</view>

		<u-picker :show="show" :immediateChange="true" :columns="list" keyName="category" @confirm="sexSelect" @cancel='show=false' closeOnClickOverlay  @close='show=false'></u-picker>
		<view class="upBtn tac colorf" @click="toSee">提交</view>
	</view>
</template>

<script>
	import {getAccumulation,setAccumulation,upDateAccumulation} from "../../api/information.js"
  import commonWin from "./commonWin.vue";
	export default {
		name:"informtionList",
    components: {commonWin},
		props:{
      flag:{
        type:Boolean,
        default:()=>{return false}
      },
      pid:{
        type:String,
        default:()=>{return ''}
      },
      ui:{
        type:String,
        default:()=>{return 0}
      },
			isThis:{
				type:Number,
				default:()=>{return ''}
			},
      listId:{
        type:String,
        default:()=>{return ''}
      }
		},
		data() {
			return {
				show:false,
				select:null,
				house:{
					userId: uni.getStorageSync('userInfo').id,
					isPayment: "",
					isHouse: "",
					propertyStatus: "",
					unitTime: "",
					natureOfUnit: "",
					job: "",
					policyYearPayment: ""
				},
				list:[]
			};
		},
		onReady() {
			if(this.isThis==5){
				this.getMessage()
			}
		},
		methods:{
			// 获取是否填写保单资料
			getMessage(){
				getAccumulation(this.ui).then(res => {
					if(res.data){
						this.house = res.data
						this.status = true
					}else{
						this.status = false
					}
				})
			},
			//提交
			toSee(){
				if(this.listId){
          this.house.id = this.listId
          uni.$u.toast('资料提交中...')
					upDateAccumulation(this.house).then(res => {
						if(res.code==0){
							uni.$u.toast('保存成功')
							setTimeout(()=>{
                uni.navigateBack()
							},500)
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}else{
          uni.$u.toast('资料提交中...')
					setAccumulation(this.house).then(res => {
						if(res.code==0){
              if (this.flag){
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=&type=1&tableId=0`
                })
              }else {
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=${this.pid}&type=0&tableId=`+res.data
                })
              }
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}
			},
			//选择
			click(i){
				this.show = true
				this.select = i
				if(i==1){
					this.list = [['是','否']]
				}
				if(i==2){
					this.list = [['是','否']]
				}
				if(i==3){
					this.list = [['无','抵押','按揭','无抵押']]
				}
				if(i==4){
					this.list = [['1个月以上','2个月以上','3个月以上','4个月以上','5个月以上','6个月以上','7个月以上','8个月以上','9个月以上','10个月以上','11个月以上','12个月以上']]
				}
				if(i==5){
					this.list = [['法人','股东','公务员','事业单位','国有企业','其他企业','金融机构','涉农企业','自由职业','教师','医生','私营企业主','学生','农民','其他']]
				}
				if(i==6){
					this.list = [['法人','股东','上班','其他']]
				}
			},
			//确认选择
			sexSelect(e){
				this.show = false
				if(this.select==1){
					this.house.isPayment = e.value[0]
				}
				if(this.select==2){
					this.house.isHouse = e.value[0]
				}
				if(this.select==3){
					this.house.propertyStatus = e.value[0]
				}
				if(this.select==4){
					this.house.unitTime = e.value[0]
				}
				if(this.select==5){
					this.house.natureOfUnit = e.value[0]
				}
				if(this.select==6){
					this.house.job = e.value[0]
				}
			}
		}
	}
</script>

<style lang="scss">
.top{
	line-height: 80rpx;
	background-color: #eaf3ff;
}
.messageBar{
	min-height: 80rpx;
	line-height: 80rpx;
	padding: 0 30rpx;
	margin-bottom: 10rpx;
	background-color: #fff;
	.select{
		image{
			width: 20rpx;
			height: 30rpx;
			margin-left: 10rpx;
		}
	}
}
.upBtn{
	width: 80%;
	line-height: 80rpx;
	border-radius: 40rpx;
	background-color: #0055ff;
	margin: 40rpx auto 20rpx;
}
</style>